//
//  BBmoneyTableViewCell.m
//  XTXOneToOne
//
//  Created by Canny on 2018/11/2.
//  Copyright © 2018年 WK. All rights reserved.
//

#import "BBmoneyTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface BBmoneyTableViewCell ()

@property (nonatomic,strong)UIImageView * imgV;
@property (nonatomic,strong)UILabel * name ;
@property (nonatomic,strong)UILabel * available  ;//  浮点型    可用余额
@property (nonatomic,strong)UILabel * frozen;

@property (nonatomic,strong)UIButton * btn1;
@property (nonatomic,strong)UIButton * btn2;

@end

@implementation BBmoneyTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self initView];
    }
    return self;
}

- (void)initView{
    
    self.backgroundColor = [UIColor whiteColor];
    
    UIImageView * imgV = [[UIImageView alloc]init];
    [self addSubview:imgV];
//    imgV.image = [UIImage imageNamed:@"银行卡"];
    [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(20);
        make.top.equalTo(self.mas_top).offset(25);
        make.height.mas_equalTo(22);
        make.width.mas_equalTo(22);
        
    }];
    imgV.layer.cornerRadius=11;
    imgV.clipsToBounds=YES;
    _imgV=imgV;
    
    UILabel * name = [[UILabel alloc]init];
    [self addSubview:name];
    [self setLab:name withColor:RGB(30, 63, 89) andFont:15 andText:@"加载中" andTextAlignment:NSTextAlignmentLeft];
    _name = name;
    [name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imgV.mas_right).offset(10);
        make.centerY.equalTo(imgV.mas_centerY).offset(0);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(200);
        
    }];
    
    UILabel * lab1 = [[UILabel alloc]init];
    [self addSubview:lab1];
    [self setLab:lab1 withColor:RGB(140, 159, 173) andFont:15 andText:@"可用" andTextAlignment:NSTextAlignmentLeft];
    [lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(name.mas_left).offset(0);
        make.top.equalTo(name.mas_bottom).offset(10);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(100);
        
    }];
    
    UILabel * available = [[UILabel alloc]init];
    [self addSubview:available];
    [self setLab:available withColor:RGB(30, 63, 89) andFont:15 andText:@"" andTextAlignment:NSTextAlignmentRight];
    [available mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-15);
        make.centerY.equalTo(lab1.mas_centerY).offset(0);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(200);
        
    }];
    
    _available = available;
    
    UILabel * lab2 = [[UILabel alloc]init];
    [self addSubview:lab2];
    [self setLab:lab2 withColor:RGB(140, 159, 173) andFont:15 andText:@"冻结" andTextAlignment:NSTextAlignmentLeft];
    [lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(name.mas_left).offset(0);
        make.top.equalTo(lab1.mas_bottom).offset(10);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(100);
        
    }];
    
    UILabel * frozen = [[UILabel alloc]init];
    [self addSubview:frozen];
    [self setLab:frozen withColor:RGB(30, 63, 89) andFont:15 andText:@"" andTextAlignment:NSTextAlignmentRight];
    [frozen mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-15);
        make.centerY.equalTo(lab2.mas_centerY).offset(0);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(200);
        
    }];
    _frozen = frozen;
    
    
    UIButton *  btn1 = [[UIButton alloc]init];
    [self addSubview:btn1];
    [btn1 setTitleColor:RGB(255,255,255) forState:UIControlStateNormal];
    [btn1 setTitle:@"充值" forState:UIControlStateNormal];
    btn1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    btn1.titleLabel.font = [UIFont systemFontOfSize: 12.0];
    [btn1 addTarget:self action:@selector(CZ_Action) forControlEvents:UIControlEventTouchUpInside];
    [btn1.layer setBorderWidth:1.0];
    btn1.layer.borderColor=ThemeColor.CGColor;
    btn1.backgroundColor=ThemeColor;
    [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(imgV.mas_centerY).offset(0);
        make.right.equalTo(self.mas_right).offset(-100);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(32);
    }];
    _btn1=btn1;
    
    UIButton *  btn2 = [[UIButton alloc]init];
    [self addSubview:btn2];
    [btn2 setTitleColor:ThemeColor forState:UIControlStateNormal];
    [btn2 setTitle:@"划转" forState:UIControlStateNormal];
    btn2.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    btn2.titleLabel.font = [UIFont systemFontOfSize: 12.0];
    [btn2 addTarget:self action:@selector(HZ_Action) forControlEvents:UIControlEventTouchUpInside];
    [btn2.layer setBorderWidth:1.0];
    btn2.layer.borderColor=ThemeColor.CGColor;
    btn2.backgroundColor=[UIColor whiteColor];
    [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(imgV.mas_centerY).offset(0);
        make.right.equalTo(self.mas_right).offset(-15);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(32);
    }];
    _btn2=btn2;
    
}

-(void)relayOut{
    
}

-(void)CZ_Action{
    if (self.block) {
        self.block(_dataSource, @"充值");
    }
}

-(void)HZ_Action{
    if (self.block) {
        self.block(_dataSource, @"划转");
    }
}
-(void)setLab:(UILabel *)lab withColor:(UIColor *)color andFont:(CGFloat)font andText:(NSString *)text andTextAlignment:(NSTextAlignment)textAlignment{
    lab.text=text;
    lab.textColor=color;
    lab.font=[UIFont systemFontOfSize:font];
    lab.textAlignment=textAlignment;
}


+(CGFloat)computeHeight:(id)info{
    return 120;
}

-(void)setDataSource:(BBlistMoneyModel *)dataSource{
    
    _dataSource = dataSource;
    if (dataSource) {
        
        [_imgV sd_setImageWithURL:[NSURL URLWithString:dataSource.logo]];
        _available.text = [NSString stringWithFormat:@"%@",dataSource.available];
        _frozen.text = [NSString stringWithFormat:@"%@",dataSource.frozen];
        _name.text = [NSString stringWithFormat:@"%@",dataSource.symbol];
        
    }
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
